home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Networking / Network Watch (DMZ) v1.5 / sources / dmzLDEF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-25  |  3.1 KB  |  127 lines  |  [TEXT/MPS ]

  1. /*
  2.   *    LDEF for dmz
  3.   *
  4.   *    v1.0 2/18/90 - pvh    
  5.   *     
  6.   *    Draws each cell.  each cell is divided into 5 Pascal based strings.  this LDEF
  7.   *    simply parses thoses strings and displays at a set incremental position.
  8.   *
  9.   *    To be safe, lock the LDEF down either when you are being called or just set the
  10.   *    lock bit on the resource (which is what we opted for).  QuickDraw may move us
  11.   *    if we're not locked down.
  12.   *
  13.   *    We're only worried about two messages here: lDrawMsg & lHiliteMsg.
  14.   */
  15.  
  16. #include    <Lists.h>
  17. #include    <Dialogs.h>
  18. #include    <AppleTalk.h>
  19. #include     "dmz.h"
  20.  
  21. void DoHilite();
  22. void DrawItem();
  23.  
  24. pascal void MAIN (short lMessage, Boolean lSelect, Rect *lRect, Cell lCell,
  25.     short lDataOffset, short lDataLen, ListHandle lHandle)
  26. {
  27.     #pragma    unused (lCell, lDataLen)
  28.  
  29.     myNetworkEntity        *bob;
  30.     FontInfo                    info;
  31.     short                        rectLeftCoord, rectTopCoord;
  32.     GrafPtr                    ourWindow;
  33.     unsigned char            handleState;
  34.         
  35.     GetPort(&ourWindow);
  36.     
  37.     switch(lMessage)
  38.         {
  39.         case lDrawMsg:
  40.             /* 
  41.               *    Just blow up. 
  42.               */
  43.             handleState = HGetState((Handle)(**lHandle).cells);
  44.             HLock((Handle)(**lHandle).cells);
  45.             EraseRect(lRect);
  46.             
  47.             /* 
  48.                *    Get our data from the cell.  Convieniently put in to our known structure. 
  49.                */
  50.             bob = (myNetworkEntity *) ((Ptr) *((Handle)(**lHandle).cells) + (long)lDataOffset);
  51.             
  52.             /* 
  53.               *    Normal drawing mode (just in case).  And get font info for drawing. 
  54.               */
  55.             PenNormal();
  56.             GetFontInfo(&info);
  57.             
  58.             /* 
  59.               *    Save these guys for later.  Save a few bytes. 
  60.               */
  61.             rectLeftCoord = lRect->left;
  62.             rectTopCoord = lRect->top + info.ascent;
  63.             
  64.             /* 
  65.               *    Draw each string as they come up. 
  66.               */
  67.             MoveTo(rectLeftCoord + 3, rectTopCoord);
  68.             DrawString((ConstStr255Param)bob->object);
  69.  
  70.             MoveTo(rectLeftCoord + 200, rectTopCoord);
  71.             DrawString((ConstStr255Param)bob->type);
  72.  
  73.             MoveTo(rectLeftCoord + 372, rectTopCoord);
  74.             DrawString((ConstStr255Param)bob->net);
  75.  
  76.             MoveTo(rectLeftCoord + 415, rectTopCoord);
  77.             DrawString((ConstStr255Param)bob->node);
  78.  
  79.             MoveTo(rectLeftCoord + 448, rectTopCoord);
  80.             DrawString((ConstStr255Param)bob->socket);
  81.  
  82.             /*
  83.             DrawItem(kObjectID, ourWindow, rectTopCoord, (char *) &bob->object, lRect);
  84.             DrawItem(kTypeID, ourWindow, rectTopCoord, (char *) &bob->type, lRect);
  85.             DrawItem(kNetID, ourWindow, rectTopCoord, (char *) &bob->net, lRect);
  86.             DrawItem(kNodeID, ourWindow, rectTopCoord, (char *) &bob->node, lRect);
  87.             DrawItem(kSocketID, ourWindow, rectTopCoord, (char *) &bob->socket, lRect);
  88.             */
  89.                 
  90.             if (lSelect)            
  91.                 DoHilite(lRect);
  92.             
  93.             HSetState((Handle)(**lHandle).cells, handleState);
  94.             break;            
  95.         case lHiliteMsg:
  96.             /* 
  97.               *    Highlight it? 
  98.               */
  99.             DoHilite(lRect);
  100.             break;
  101.         default:
  102.             break;
  103.         }
  104.         
  105. }
  106.  
  107. void DoHilite(Rect    *lRect)
  108. {
  109.     BitClr((Ptr) HiliteModePtr, pHiliteBit);  /* use color if we got it! */
  110.     InvertRect(lRect);
  111. }
  112.  
  113. void DrawItem(short whichItem, WindowPtr ourWindow, short topCoord, char *itemString,
  114.     Rect *lRect)
  115. {
  116.     #pragma unused (lRect)
  117.  
  118.     short        kind;
  119.     Handle        h;
  120.     Rect            r;
  121.  
  122.     GetDItem((DialogPtr) ourWindow, whichItem, &kind, &h, &r);
  123.     MoveTo(r.left, topCoord);
  124.     DrawString((ConstStr255Param)itemString);
  125. }
  126.  
  127.